/*
Flickr Photosets - Configure Page Javascript

author Brad Dougherty <bdougherty@gmail.com>
license http://www.gnu.org/licenses/gpl.html GNU General Public License 3.0
*/

// All of the elements referenced
var profile_display_small = $("profile_display_small");
var profile_display_label = $("profile_display_label");
var profile_tags_field = $('profile_tags_field');
var profile_tagmode_field = $('profile_tagmode_field');
var profile_sortby_field = $('profile_sortby_field');
var num_photos_field = $('num_photos_field');

// Changes the "Number of ..." string
function changeNumPhotos(string) {
	if (string == 'Sets') {
		profile_display_label.setTextValue("Number of Sets:");
		profile_display_small.setTextValue("Maximum 30 sets");
	}
	else {
		profile_display_label.setTextValue("Number of Photos:");
		profile_display_small.setTextValue("Maximum 30 photos");
	}
}

// Checks to make sure that the user enters no more than 30 sets/photos
function checkNumPhotos(obj) {
	var value = obj.getValue();
	if (value > 30) {
		var alert = new Dialog(Dialog.DIALOG_CONTEXTUAL);
		alert.onconfirm = function() {
			alert.hide();
			obj.setValue('30');
			obj.focus();
		}
		alert.setContext(profile_display_label);
		alert.showMessage('You have specified too many photos or photosets.', 'You can only show up to 30 photos or photosets.');
	}
}

// Hides and shows profile page options
function profilePageOptions(obj) {
	var selected = obj.getValue();
	
	// Sets
	if (selected == profile_display_sets || selected == profile_display_random_sets) {
		// Hide these
		profile_tags_field.style.display = 'none';
		profile_tagmode_field.style.display = 'none';
		profile_sortby_field.style.display = 'none';
		
		// Show these
		num_photos_field.style.display = '';
		
		// Change the num_photos_field text
		changeNumPhotos('Sets');
	}
	// Overview
	else if (selected == profile_display_overview) {
		// Hide these
		num_photos_field.style.display = 'none';
		profile_tags_field.style.display = 'none';
		profile_tagmode_field.style.display = 'none';
		profile_sortby_field.style.display = 'none';
	}
	// Photos
	else {
		// Show these
		num_photos_field.style.display = '';
		profile_tags_field.style.display = '';
		profile_tagmode_field.style.display = '';
		profile_sortby_field.style.display = '';
		
		// Change the num_photos_field text
		changeNumPhotos('Photos');
	}
	
}